// 接口 Interface
// 可选成员、只读成员、动态成员

export {}

interface Post {
    title: string
    content: string
    subtitle?: string//可选成员
    readonly summary: string//只读成员
}

function printPost(post: Post): void{
    console.log(post.title)
    console.log(post.content)
}

printPost({
    title: 'hello ts',
    content: 'a js superset',
    summary: 'summary'
})

const hello: Post = {
    title: 'hello ts hello',
    content: 'a js superset hello',
    summary: 'summary hello'
}
// hello.summary = 'hello'



// -----------------------
// 动态成员
interface Cache {
    [key: string]: string
}

const cache: Cache = {}

cache.foo = 'foo'
cache.bar = 'bar'
cache.baz = 'baz'























